#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;
using tl = tuple < int, int, int >;

const int N = 1e5 + 10;

int n, m, K;
set < int > G[N];
bool vis[N];
vec ans;

void dfs(int x) {
	ans.pb(x); vis[x] = 1;
	for(auto y : G[x]) if(!vis[y]) dfs(y);
}

bool check(int x) {
	vec al; al.eb(x);
	for(auto y : G[x]) {
		if(G[y].size() < K - 1) return 0;
		for(auto v : al) if(!G[v].count(y)) return 0;
		al.eb(y);
	} return true;
}

void solve() {
	n = in, m = in, K = in;
	rep(i, 1, n) vis[i] = 0, G[i].clear();
	rep(i, 1, m) {
		int u = in, v = in;
		G[u].ep(v); G[v].ep(u);
	}
	if(K == 1) return puts("2\n1"), void();
	queue < int > q;
	rep(i, 1, n) {
		if(G[i].size() < K - 1) vis[i] = 1, q.ep(i);
		else if(G[i].size() == K - 1) {
			if(1ll * K * (K - 1) <= 2 * m && check(i)) {
				puts("2");
				for(auto v : G[i]) printf("%d ", v);
				printf("%d\n", i); return;
			} else vis[i] = 1, q.ep(i);
		}
	}
	while(q.size()) {
		int x = q.front(); q.pop();
		for(auto y : G[x]) {
			G[y].erase(x);
			if(G[y].size() < K - 1) {
				if(!vis[y]) vis[y] = 1, q.ep(y);
			}
			else if(1ll * K * (K - 1) <= 2 * m && G[y].size() == K - 1) {
				if(check(y)) {
					puts("2");
					for(auto v : G[y]) printf("%d ", v);
					printf("%d\n", y); return;
				} else if(!vis[y]) vis[y] = 1, q.ep(y);
			}
		} G[x].clear();
	}
	rep(i, 1, n) if(!vis[i]) {
		dfs(i); printf("1 %lu\n", ans.size()); for(auto v : ans) printf("%d ", v); puts(""); ans.clear(); return;
	} puts("-1");
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	int T = in; while(T--) solve();
	return 0;
}
